package com.xy.demo.controller;


import com.xy.demo.DesignMode.AdapterPattern.AdapterClass;
import com.xy.demo.DesignMode.AdapterPattern.AdapterObject;
import com.xy.demo.DesignMode.AdapterPattern.ConcreteTarget;
import com.xy.demo.DesignMode.AdapterPattern.Target;
import com.xy.demo.model.Params;
import com.xy.demo.model.ResultInfo;
import com.xy.demo.service.RoleService;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;



@RequestMapping("/role")
@RestController
public class RoleController {

    @Autowired
    private RoleService roleService;

    @RequestMapping("/getAll")
    private ResultInfo getAll(){
        Params params =new Params();
        ResultInfo roles = roleService.getAll(params);
        return roles;
    }

    @RequestMapping("/test")
    private String test(){

        return "成功,四次推送";
    }

    /**
     * @description:
     * @author: yang
     * @date: 2023/8/3 17:40
     * @param:
     * @return: 
     **/
    private void setExcelRespProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException {
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("", "%20");
        response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xls");


    }

}
